]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/system: Add screenshot item
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 21 Aug 2022 16:23:06 +0000 (18:23 +0200)
committerMarge Bot <marge-bot@gnome.org>
Mon, 22 Aug 2022 14:15:17 +0000 (14:15 +0000)
We got a shiny new screenshot UI last cycle, but only relatively
obscure ways of launching it: Keyboard shortcut or overview search.

The new quick settings provides us with a natural place to expose
the functionality more prominently, and at the same time reduce
the emptiness of the top row, in particular on systems without a
battery and when locked.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2439>

js/ui/status/system.js

index a45697adb48d04781390b6b7fd9c8af8c4cf0243..45773072256bd2d8ae579f98e99bb0b8c9507727 100644 (file)
@@ -1,11 +1,12 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported Indicator */
 
-const {Atk, Clutter, Gio, GObject, Shell, St, UPowerGlib: UPower} = imports.gi;
+const {Atk, Clutter, Gio, GLib, GObject, Meta, Shell, St, UPowerGlib: UPower} = imports.gi;
 
 const SystemActions = imports.misc.systemActions;
 const Main = imports.ui.main;
 const PopupMenu = imports.ui.popupMenu;
+const {PopupAnimation} = imports.ui.boxpointer;
 
 const {QuickSettingsItem, QuickToggle, SystemIndicator} = imports.ui.quickSettings;
 const {loadInterfaceXML} = imports.misc.fileUtils;
@@ -93,6 +94,27 @@ const PowerToggle = GObject.registerClass({
     }
 });
 
+const ScreenshotItem = GObject.registerClass(
+class ScreenshotItem extends QuickSettingsItem {
+    _init() {
+        super._init({
+            style_class: 'icon-button',
+            can_focus: true,
+            icon_name: 'camera-photo-symbolic',
+            visible: !Main.sessionMode.isGreeter,
+        });
+
+        this.connect('clicked', () => {
+            const topMenu = Main.panel.statusArea.quickSettings.menu;
+            Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
+                Main.screenshotUI.open().catch(logError);
+                return GLib.SOURCE_REMOVE;
+            });
+            topMenu.close(PopupAnimation.NONE);
+        });
+    }
+});
+
 const SettingsItem = GObject.registerClass(
 class SettingsItem extends QuickSettingsItem {
     _init() {
@@ -242,6 +264,9 @@ class SystemItem extends QuickSettingsItem {
             GObject.BindingFlags.SYNC_CREATE);
         this.child.add_child(this._laptopSpacer);
 
+        const screenshotItem = new ScreenshotItem();
+        this.child.add_child(screenshotItem);
+
         const settingsItem = new SettingsItem();
         this.child.add_child(settingsItem);